package com.brokendust.client.config.module.item;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.crash.ReportedException;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.JsonToNBT;

public class ItemEntityJson {
    public String type;
    private String objectName;
    private String uuidString;
    private String item;
    private float scale;
    private double locationHeight;
    private double locationAngle;
    private double locationDistance;
    private float rotateX;
    private float rotateY;
    private float rotateZ;
    private int autoRotationX;
    private int autoRotationY;
    private int autoRotationZ;

    public ItemEntityJson() {
        this.type = "Item";
        this.objectName = "";
        this.item = "";
    }

    public static ItemEntityJson readJSON(String string) {
        GsonBuilder builder = new GsonBuilder();
        Gson gson = builder.create();
        return gson.fromJson(string, ItemEntityJson.class);
    }

    public ItemStack getItemStack() {
        ItemStack itemStack = null;
        try {
            CompoundNBT compound = JsonToNBT.parseTag(this.item);
            itemStack = ItemStack.of(compound);
        } catch (CommandSyntaxException | ReportedException e) {
            e.printStackTrace();
        }
        return itemStack;
    }

    public String getUuidString() {
        return this.uuidString;
    }

    public void setUuidString(String uuidString) {
        this.uuidString = uuidString;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getObjectName() {
        return this.objectName;
    }

    public void setObjectName(String objectName) {
        this.objectName = objectName;
    }

    public String getItem() {
        return this.item;
    }

    public void setItem(String item) {
        this.item = item;
    }

    public float getScale() {
        return this.scale;
    }

    public void setScale(float scale) {
        this.scale = scale;
    }

    public double getLocationHeight() {
        return this.locationHeight;
    }

    public void setLocationHeight(double locationHeight) {
        this.locationHeight = locationHeight;
    }

    public double getLocationAngle() {
        return this.locationAngle;
    }

    public void setLocationAngle(double locationAngle) {
        this.locationAngle = locationAngle;
    }

    public double getLocationDistance() {
        return this.locationDistance;
    }

    public void setLocationDistance(double locationDistance) {
        this.locationDistance = locationDistance;
    }

    public float getRotateX() {
        return this.rotateX;
    }

    public void setRotateX(float rotateX) {
        this.rotateX = rotateX;
    }

    public float getRotateY() {
        return this.rotateY;
    }

    public void setRotateY(float rotateY) {
        this.rotateY = rotateY;
    }

    public float getRotateZ() {
        return this.rotateZ;
    }

    public void setRotateZ(float rotateZ) {
        this.rotateZ = rotateZ;
    }

    public int getAutoRotationX() {
        return this.autoRotationX;
    }

    public void setAutoRotationX(int autoRotationX) {
        this.autoRotationX = autoRotationX;
    }

    public int getAutoRotationY() {
        return this.autoRotationY;
    }

    public void setAutoRotationY(int autoRotationY) {
        this.autoRotationY = autoRotationY;
    }

    public int getAutoRotationZ() {
        return this.autoRotationZ;
    }

    public void setAutoRotationZ(int autoRotationZ) {
        this.autoRotationZ = autoRotationZ;
    }
}
